import { Prisma } from '@prisma/client';
import { Transform } from 'class-transformer';
import { IsDefined, IsNotEmptyObject } from 'class-validator';
import { BaseDto, BaseFindDto, BaseQueryDto } from './base.dto';

export class InvoiceOrderCreateDto extends BaseDto<Prisma.InvoiceOrderCreateInput> {}

export class InvoiceOrderUpdateDto extends BaseDto<Prisma.InvoiceOrderUpdateInput> {
  @IsDefined({ message: '条件必填' })
  @IsNotEmptyObject({ nullable: false }, { message: '条件参数必填' })
  where: Prisma.InvoiceOrderWhereUniqueInput;
}

export class InvoiceOrderRemoveDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;
}

export class InvoiceOrderFindDto extends BaseFindDto<
  Prisma.InvoiceOrderWhereUniqueInput,
  Prisma.InvoiceOrderSelect
> {}

export class InvoiceOrderQueryDto extends BaseQueryDto<
  Prisma.InvoiceOrderWhereUniqueInput & {
    startTime?: string;
    endTime?: string;
    realname?: string;
    mobile?: string;
  }
> {}

export class InvoiceOrderDispatchDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;

  @IsDefined({ message: '发货单号必填' })
  no: string;
}
